'''
RobotScript
Created on 1. jan. 2013

@author: Marko Mladenovic
'''

import sys, getopt, compiler

def main(argv):
    header = '''
    robotScript 0.0.1
    Created by: Marko Mladenovic <mladenkoml@gmail.com>
    '''
    usage = '''
    robotscript.py -i <input file> -o <output file> -r <robot>
    '''
    inputfile = ''
    outputfile= ''
    global robot
    global server
    global client
    
    try:
        opts,args = getopt.getopt(argv,"anhi:o:r:",['net', 'all','help','ifile=','ofile=','robot='])
    except getopt.GetoptError:
        print(usage)
        sys.exit(2)
    if opts == []:
        print(usage)
        sys.exit()
    elif args == []:
        print (usage)
        sys.exit()
    for opt, arg in opts:
       if opt in ('-h', '--help'):
            print (usage)
            sys.exit()
       elif opt in ('-i', '--ifile'):
            inputfile = arg
       elif opt in ('-o', '--ofile'):
            outputfile = arg
       elif opt in ('-r', '--robot'):
            robot = arg
       elif opt in ('-a', '--all'):
            robot = all
       elif opt in ('-n', '--net'):
           server
    try:
        print (header)
        comp = compiler.compile(inputfile, outputfile, robot)
        comp.start()
    except:
        print ("Can't start compiler")
        
        
if __name__ == '__main__':
    main(sys.argv[1:])
    